#define DEBUG
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

const int maxn=3000000;

class Side {
public:
  int a, b, v;

  static bool cmp(const Side &a, const Side &b) {
    return a.v>b.v;
  }
};

void initSet(int n, int set[]) {
  for (int i=1; i<=n; i++) {
    set[i] = i;
  }
}

int getFa(int f[], int o) {
  return f[o] = (f[o]!=o ? getFa(f, f[o]) : o);
}

int solve(int n, int node[], Side sides[]) {
  static int set[maxn+1], ans[maxn+1];
  initSet(n, set);
  for (int i=1; i<=n; i++) {
    ans[i] = node[i];
  }
  ans[0] = 0;
  for (int i=1; i<n; i++) {
    int x=getFa(set, sides[i].a), y=getFa(set, sides[i].b);
    set[y] = x;
    ans[x] += ans[y], ans[y]=0;
    ans[0] = max(ans[0], ans[x]*sides[i].v);
  }
  return ans[0];
}

int main() {
  freopen("tree.in", "r", stdin);
  freopen("tree.out", "w", stdout);

  static Side sides[maxn+1];
  static int node[maxn+1];
  int n, m;
  scanf("%d %d", &n, &m);
  for (int i=1; i<=n; i++) {
    scanf("%d", node+i);
  }
  for (int i=1; i<n; i++) {
    scanf("%d %d %d", &sides[i].a, &sides[i].b, &sides[i].v);
  }
  sort(sides+1, sides+n+1, Side::cmp);

  for (int i=1; i<=m; i++) {
    int u, val;
    scanf("%d %d", &u, &val);
    node[u] = val;

    printf("%d\n", solve(n, node, sides));
  }

  fclose(stdin);
  fclose(stdout);
  return 0;
}
